#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
const int maxn = 100;
int F[maxn];

void init(int n) {
    for (int i = 1; i <= n; i++) {
        F[i] = i;
    }
}

bool is_root(int x) {
    return F[x] == x;
}

int find(int x) {
    if (is_root(x))return x;
    return F[x] = find(F[x]);
}

bool merge(int x, int y) {
    int fx = find(x), fy = find(y);
    if(fx==fy)return false;
    F[fx] = fy;
    return true;
}
int count(int n){
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(F[i]==i)++cnt;
    }
    return cnt;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    while (cin >> n >> m) {
        init(n);
        copy(F+1,F+n+1,ostream_iterator<int>(cerr," "));
        cerr<<endl;
        while(m--){
            int x,y;
            cin>>x>>y;
            merge(x,y);
            copy(F+1,F+n+1,ostream_iterator<int>(cerr," "));
            cerr<<endl;
        }
        cout<<count(n)<<endl;
    }
    return 0;
}